/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package modelo;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Santiago.Escobar.M
 */
@Entity
@Table(name = "vehiculo")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Vehiculo.findAll", query = "SELECT v FROM Vehiculo v"),
    @NamedQuery(name = "Vehiculo.findByPlaca", query = "SELECT v FROM Vehiculo v WHERE v.placa = :placa"),
    @NamedQuery(name = "Vehiculo.findByMatricula", query = "SELECT v FROM Vehiculo v WHERE v.matricula = :matricula"),
    @NamedQuery(name = "Vehiculo.findByKilometros", query = "SELECT v FROM Vehiculo v WHERE v.kilometros = :kilometros"),
    @NamedQuery(name = "Vehiculo.findByFechamatricula", query = "SELECT v FROM Vehiculo v WHERE v.fechamatricula = :fechamatricula"),
    @NamedQuery(name = "Vehiculo.findByMotor", query = "SELECT v FROM Vehiculo v WHERE v.motor = :motor"),
    @NamedQuery(name = "Vehiculo.findByChasis", query = "SELECT v FROM Vehiculo v WHERE v.chasis = :chasis"),
    @NamedQuery(name = "Vehiculo.findByColor", query = "SELECT v FROM Vehiculo v WHERE v.color = :color"),
    @NamedQuery(name = "Vehiculo.findByNumerollantas", query = "SELECT v FROM Vehiculo v WHERE v.numerollantas = :numerollantas"),
    @NamedQuery(name = "Vehiculo.findByFechaalta", query = "SELECT v FROM Vehiculo v WHERE v.fechaalta = :fechaalta"),
    @NamedQuery(name = "Vehiculo.findByFechabaja", query = "SELECT v FROM Vehiculo v WHERE v.fechabaja = :fechabaja"),
    @NamedQuery(name = "Vehiculo.findByEstado", query = "SELECT v FROM Vehiculo v WHERE v.estado = :estado"),
    @NamedQuery(name = "Vehiculo.findByUbicacion", query = "SELECT v FROM Vehiculo v WHERE v.ubicacion = :ubicacion"),
    @NamedQuery(name = "Vehiculo.findByDescripcion", query = "SELECT v FROM Vehiculo v WHERE v.descripcion = :descripcion")})
public class Vehiculo implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 10)
    @Column(name = "placa")
    private String placa;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 10)
    @Column(name = "matricula")
    private String matricula;
    @Basic(optional = false)
    @NotNull
    @Column(name = "kilometros")
    private int kilometros;
    @Basic(optional = false)
    @NotNull
    @Column(name = "fechamatricula")
    @Temporal(TemporalType.DATE)
    private Date fechamatricula;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "motor")
    private String motor;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "chasis")
    private String chasis;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 10)
    @Column(name = "color")
    private String color;
    @Basic(optional = false)
    @NotNull
    @Column(name = "numerollantas")
    private int numerollantas;
    @Basic(optional = false)
    @NotNull
    @Column(name = "fechaalta")
    @Temporal(TemporalType.DATE)
    private Date fechaalta;
    @Column(name = "fechabaja")
    @Temporal(TemporalType.DATE)
    private Date fechabaja;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 2)
    @Column(name = "estado")
    private String estado;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "ubicacion")
    private String ubicacion;
    @Size(max = 250)
    @Column(name = "descripcion")
    private String descripcion;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "placa")
    private Collection<Recargacombustiblevehiculo> recargacombustiblevehiculoCollection;
    @OneToMany(mappedBy = "placa")
    private Collection<Responsablevehiculo> responsablevehiculoCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "placa")
    private Collection<Rutavehiculo> rutavehiculoCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "placa")
    private Collection<Vehiculooficina> vehiculooficinaCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "placa")
    private Collection<Trabajo> trabajoCollection;
    @JoinColumns({
        @JoinColumn(name = "marca", referencedColumnName = "marca"),
        @JoinColumn(name = "modelo", referencedColumnName = "modelo")})
    @ManyToOne
    private Modelovehiculo modelovehiculo;

    public Vehiculo() {
    }

    public Vehiculo(String placa) {
        this.placa = placa;
    }

    public Vehiculo(String placa, String matricula, int kilometros, Date fechamatricula, String motor, String chasis, String color, int numerollantas, Date fechaalta, String estado, String ubicacion) {
        this.placa = placa;
        this.matricula = matricula;
        this.kilometros = kilometros;
        this.fechamatricula = fechamatricula;
        this.motor = motor;
        this.chasis = chasis;
        this.color = color;
        this.numerollantas = numerollantas;
        this.fechaalta = fechaalta;
        this.estado = estado;
        this.ubicacion = ubicacion;
    }

    public String getPlaca() {
        return placa;
    }

    public void setPlaca(String placa) {
        this.placa = placa;
    }

    public String getMatricula() {
        return matricula;
    }

    public void setMatricula(String matricula) {
        this.matricula = matricula;
    }

    public int getKilometros() {
        return kilometros;
    }

    public void setKilometros(int kilometros) {
        this.kilometros = kilometros;
    }

    public Date getFechamatricula() {
        return fechamatricula;
    }

    public void setFechamatricula(Date fechamatricula) {
        this.fechamatricula = fechamatricula;
    }

    public String getMotor() {
        return motor;
    }

    public void setMotor(String motor) {
        this.motor = motor;
    }

    public String getChasis() {
        return chasis;
    }

    public void setChasis(String chasis) {
        this.chasis = chasis;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public int getNumerollantas() {
        return numerollantas;
    }

    public void setNumerollantas(int numerollantas) {
        this.numerollantas = numerollantas;
    }

    public Date getFechaalta() {
        return fechaalta;
    }

    public void setFechaalta(Date fechaalta) {
        this.fechaalta = fechaalta;
    }

    public Date getFechabaja() {
        return fechabaja;
    }

    public void setFechabaja(Date fechabaja) {
        this.fechabaja = fechabaja;
    }

    public String getEstado() {
        return estado;
    }

    public void setEstado(String estado) {
        this.estado = estado;
    }

    public String getUbicacion() {
        return ubicacion;
    }

    public void setUbicacion(String ubicacion) {
        this.ubicacion = ubicacion;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    @XmlTransient
    public Collection<Recargacombustiblevehiculo> getRecargacombustiblevehiculoCollection() {
        return recargacombustiblevehiculoCollection;
    }

    public void setRecargacombustiblevehiculoCollection(Collection<Recargacombustiblevehiculo> recargacombustiblevehiculoCollection) {
        this.recargacombustiblevehiculoCollection = recargacombustiblevehiculoCollection;
    }

    @XmlTransient
    public Collection<Responsablevehiculo> getResponsablevehiculoCollection() {
        return responsablevehiculoCollection;
    }

    public void setResponsablevehiculoCollection(Collection<Responsablevehiculo> responsablevehiculoCollection) {
        this.responsablevehiculoCollection = responsablevehiculoCollection;
    }

    @XmlTransient
    public Collection<Rutavehiculo> getRutavehiculoCollection() {
        return rutavehiculoCollection;
    }

    public void setRutavehiculoCollection(Collection<Rutavehiculo> rutavehiculoCollection) {
        this.rutavehiculoCollection = rutavehiculoCollection;
    }

    @XmlTransient
    public Collection<Vehiculooficina> getVehiculooficinaCollection() {
        return vehiculooficinaCollection;
    }

    public void setVehiculooficinaCollection(Collection<Vehiculooficina> vehiculooficinaCollection) {
        this.vehiculooficinaCollection = vehiculooficinaCollection;
    }

    @XmlTransient
    public Collection<Trabajo> getTrabajoCollection() {
        return trabajoCollection;
    }

    public void setTrabajoCollection(Collection<Trabajo> trabajoCollection) {
        this.trabajoCollection = trabajoCollection;
    }

    public Modelovehiculo getModelovehiculo() {
        return modelovehiculo;
    }

    public void setModelovehiculo(Modelovehiculo modelovehiculo) {
        this.modelovehiculo = modelovehiculo;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (placa != null ? placa.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Vehiculo)) {
            return false;
        }
        Vehiculo other = (Vehiculo) object;
        if ((this.placa == null && other.placa != null) || (this.placa != null && !this.placa.equals(other.placa))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "modelo.Vehiculo[ placa=" + placa + " ]";
    }
    
}
